package com.javafactroy.kunlong.bip.icp.message.data.netty.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import com.javafactroy.kunlong.bip.icp.message.dxp.base.DxpMsg;

import java.util.List;

public class AppByte2MsgDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {

        int len = byteBuf.readableBytes();
        byte[] bytes = new byte[len];
        byteBuf.readBytes(bytes);
        DxpMsg msg = new DxpMsg();
        msg.decode(bytes);
        list.add(msg);
        //ReferenceCountUtil.release(byteBuf);
    }
}
